/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gitee.fdc.base.utils;

import java.util.ArrayList;
import java.util.List;
import com.gitee.fdc.base.entity.TreeEntity;
import com.gitee.fdc.web.ztree.ZTreeNode;

/**
 *
 * @author MACHENIKE
 */
public class ZTreeUtils {
    
    public static List<ZTreeNode> ConvertFromBaseTree(List l) {
        List<ZTreeNode> zl = new ArrayList();
        for (Object z : l) {
            zl.add(convertFromTreeEntity((TreeEntity) z));
        }
        return zl;
    }
    
    public static ZTreeNode convertFromTreeEntity(TreeEntity t) {
        ZTreeNode z = new ZTreeNode();
        z.setId(t.getId());
        z.setName(t.getDisplayName());
        if (t.getPid() == null) {
            z.setpId(0);
        } else {
            z.setpId(t.getPid());
        }
        return z;
    }
}
